import java.util.ArrayList;


public class Board {
	private Block[] block = new Block[40];
	private int Location=0;
	private String[] nameList = { "Go!", "images/Scroll/200x200/1.png", "Community Chest", "Leeds", "Income Tax",
								"Glasgow Airport", "Middlesbrough", "Chance", "Cardiff", "York",
								     "Jail", "Colchester", "Telecoms", "Manchester", "London",
						    	"Belfast Airport", "Derby", "Community Chest", "Plymouth", "Lincoln",
								    	"Free Parking", "Dundee", "Chance", "Keele", "Norwich",
								"Cardiff Airport", "Birmingham", "Oxford", "Satellite", "Stoke on Trent",
								"Go to Jail", "Sheffield", "Cambridge", "Community Chest", "Nottingham",
								"Luton Airport", "Chance", "Exeter", "Super Tax", "St. Albans"};
	private Integer[] priceList = { 0, 600000, 0, 600000, 0, 2000000, 1000000, 0, 1000000, 1200000, 0, 1400000,
									1500000, 1400000, 1600000, 2000000, 1800000, 1800000, 0, 2000000, 0,
									2200000, 0, 2200000, 2400000, 2000000, 2600000, 2600000, 1500000,
									2800000, 0, 3000000, 3000000, 0, 3200000, 2000000, 0, 3500000, 0, 4000000 };
	private ArrayList<Integer> paymentList1, paymentList2, paymentList3, paymentList4, paymentList5, paymentList6, paymentList7;
	
	public Board(){
		createProperties();
	}
	
	public Block getProperty(int i){
		return block[i];
	}
	
	public Block getProperty1(int i){
		if(i==0)i=1;
		else if(i==1)i=3;
		else if(i==2)i=6;
		else if(i==3)i=8;
		else if(i==4)i=9;
		else if(i==5)i=11;
		else if(i==6)i=13;
		else if(i==7)i=14;
		else if(i==8)i=16;
		else if(i==9)i=18;
		else if(i==10)i=19;
		else if(i==11)i=21;
		else if(i==12)i=23;
		else if(i==13)i=24;
		else if(i==14)i=26;
		else if(i==15)i=27;
		else if(i==16)i=29;
		else if(i==17)i=31;
		else if(i==18)i=32;
		else if(i==19)i=34;
		else if(i==20)i=37;
		else if(i==21)i=39;
		return block[i];
	}
	
	public String getNameOfProperty(int i){
		String name;
		if(i<0){
			i = 39;
		}
		if(i == 0 || i == 10 || i == 20 || i == 30){
			name = block[i].getMyName();
		}
		else if(i == 2 || i == 17 || i == 33){
			name = block[i].getChest().getMyName();
		}
		else if(i == 7 || i == 22 || i == 36){
			name = block[i].getChance().getMyName();
		}
		else if(i == 4 || i == 38){
			name = block[i].getTax().getMyName();
		}
		else if(i == 5 || i == 15 || i == 25 || i == 35){
			name = block[i].getAirport().getMyName();
		}
		else if(i == 12 || i == 28){
			name = block[i].getUtility().getMyName();
		}
		else{
			name = block[i].getEstate().getMyName();
		}
		return name;
	}
	
	public void createPayment(){
		paymentList1 = new ArrayList<Integer>();
		paymentList2 = new ArrayList<Integer>();
		paymentList3 = new ArrayList<Integer>();
		paymentList4 = new ArrayList<Integer>();
		paymentList5 = new ArrayList<Integer>();
		paymentList6 = new ArrayList<Integer>();
		paymentList7 = new ArrayList<Integer>();
		
		paymentList1.add(20000);
		paymentList1.add(40000);
		paymentList1.add(60000);
		paymentList1.add(60000);
		paymentList1.add(80000);
		paymentList1.add(100000);
		paymentList1.add(100000);
		paymentList1.add(120000);
		paymentList1.add(140000);
		paymentList1.add(140000);
		paymentList1.add(160000);
		paymentList1.add(180000);
		paymentList1.add(180000);
		paymentList1.add(200000);
		paymentList1.add(220000);
		paymentList1.add(220000);
		paymentList1.add(240000);
		paymentList1.add(260000);
		paymentList1.add(260000);
		paymentList1.add(280000);
		paymentList1.add(350000);
		paymentList1.add(500000);
		
		for (int i = 0; i < 22; i++) {
			paymentList2.add(paymentList1.get(i)*2);
		}
		
		for (int i = 0; i < 22; i++) {
			if(i == 19)paymentList3.add(1500000);
			else paymentList3.add(paymentList1.get(i)*5);
		}
		
		for (int i = 0; i < 22; i++) {
			if(i == 4)paymentList4.add(1000000);
			else if(i == 9 || i == 8)paymentList4.add(2000000);
			else if(i == 10)paymentList4.add(2200000);
			else if(i == 11 || i == 12)paymentList4.add(2500000);
			else if(i == 20)paymentList4.add(5000000);
			else paymentList4.add(paymentList3.get(i)*3);
		}
		
		for(int i = 0; i < 22; i++){
			if(i == 7)paymentList5.add(5000000);
			else if(i == 8 || i == 8)paymentList5.add(5500000);
			else if(i == 10)paymentList5.add(6000000);
			else if(i == 11 || i == 12)paymentList5.add(7000000);
			else if(i == 13)paymentList5.add(7500000);
			else if(i == 14 || i == 15)paymentList5.add(8000000);
			else if(i == 16)paymentList5.add(8500000);
			else if(i == 17 || i == 18)paymentList5.add(9000000);
			else if(i == 19)paymentList5.add(10000000);
			else if(i == 20)paymentList5.add(11000000);
			else if(i == 21)paymentList5.add(14000000);
			else paymentList5.add(paymentList4.get(i)*3);
		}
		
		paymentList6.add(1600000);
		paymentList6.add(3200000);
		paymentList6.add(4000000);
		paymentList6.add(4000000);
		paymentList6.add(4500000);
		paymentList6.add(6250000);
		paymentList6.add(6250000);
		paymentList6.add(7000000);
		paymentList6.add(7500000);
		paymentList6.add(7500000);
		paymentList6.add(8000000);
		paymentList6.add(8750000);
		paymentList6.add(8750000);
		paymentList6.add(9250000);
		paymentList6.add(9750000);
		paymentList6.add(9750000);
		paymentList6.add(10250000);
		paymentList6.add(11000000);
		paymentList6.add(11000000);
		paymentList6.add(12000000);
		paymentList6.add(13000000);
		paymentList6.add(17000000);
		
		paymentList7.add(2500000);
		paymentList7.add(4500000);
		paymentList7.add(5500000);
		paymentList7.add(5500000);
		paymentList7.add(6000000);
		paymentList7.add(7500000);
		paymentList7.add(7500000);
		paymentList7.add(9000000);
		paymentList7.add(9500000);
		paymentList7.add(9500000);
		paymentList7.add(10000000);
		paymentList7.add(10500000);
		paymentList7.add(10500000);
		paymentList7.add(11000000);
		paymentList7.add(11500000);
		paymentList7.add(11500000);
		paymentList7.add(12000000);
		paymentList7.add(12750000);
		paymentList7.add(12750000);
		paymentList7.add(14000000);
		paymentList7.add(15000000);
		paymentList7.add(20000000);
	}
	
	public void createProperties(){
		this.createPayment();
		int counter=0;
		for (int i = 0; i < 40; i++) {
			if(i == 2 || i == 17 || i == 33){
				//createCommunityChest
				block[i] = new Block(new CommunityChest(nameList[i], Location));
			}
			else if(i == 7 || i == 22 || i == 36){
				//createChance
				block[i] = new Block(new Chance(nameList[i], Location));
			}
			else if(i == 0 || i == 10 || i == 20 || i == 30){
				//createSpecialTiles
				block[i] = new Block(nameList[i], Location);
			}
			else if(i == 4 || i == 38){
				//createTax
				block[i] = new Block(new Tax(nameList[i], Location));
			}
			else if(i == 5 || i == 15 || i == 25 || i == 35){
				//createLocation
				block[i] = new Block(new Airport(nameList[i], Location, priceList[i], 250000, 500000, 1000000, 2000000));
			}
			else if(i == 12 || i == 28){
				//createUtilities
				block[i] = new Block(new Utility(nameList[i], Location, priceList[i], 40000, 100000));
			}
			else{
				//createProperties
				block[i] = new Block(new Estate(nameList[i], Location, priceList[i], paymentList1.get(counter), paymentList2.get(counter), paymentList3.get(counter), paymentList4.get(counter), paymentList5.get(counter), paymentList6.get(counter), paymentList7.get(counter)));
				counter++;
			}
			Location++;
		}
	}
}
